package com.liuhaoqi.raletiveblog.service.Impl;

import com.liuhaoqi.raletiveblog.entity.Category;
import com.liuhaoqi.raletiveblog.mapper.CategoryMapper;
import com.liuhaoqi.raletiveblog.result.business.PageResult.CategoryPageResult;
import com.liuhaoqi.raletiveblog.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author liuhaoqi
 * @Date 2020/4/20 15:30
 * @Version 1.0
 */
@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    CategoryMapper categoryMapper;

    @Override
    public int addCategory(String categoryname) {
        Category category = new Category();
        category.setCategoryname(categoryname);
        return categoryMapper.insertCategory(category);
    }

    @Override
    public int deleteCategoryByCategoryId(Long categoryId) {
        return categoryMapper.deleteCategoryByCategoryId(categoryId);
    }

    @Override
    public List<CategoryPageResult> getAdminCategoryList(int start,int end,int pagesize) {
        return categoryMapper.getAdminCategoryList(start,end,pagesize);
    }

    @Override
    public int updateCategoryByCategoryId(Category category) {
        return categoryMapper.updateCategoryByCategoryId(category);
    }

    @Override
    public int insertCategory(Category category) {
        int categoryid = categoryMapper.insertCategory(category);
        return categoryid;
    }

    @Override
    public List<Category> getCategoryList() {
        List<Category> categoryList = categoryMapper.getCategoryList();
        return categoryList;
    }

    @Override
    public Category getCategoryByCategoryName(String categoryname) {
        return categoryMapper.getCategoryByCategoryName(categoryname);
    }
}
